import {reqGetSearchInfo} from "@/api"
const state = {
    searchList:{}
}
const mutations = {
    GETSEARCHLIST(state,searchList) {
        state.searchList = searchList
    }
}
const actions = {
    // 获取其search模块数据 默认参数
    async getSearchList({commit},value={}) {
        // 这个函数调用的时候需要传递一个参数（空对象）
        // 当用户派发action时传递过来的
        let result = await reqGetSearchInfo(value);
        if(result.code == 200) {
            commit('GETSEARCHLIST',result.data)
        }
    }
}
const getters = {
    // 当前仓库的state
    // 假如不给力state.searchList.goodsList应该返回的是undefined
    goodsList(state) {
        return state.searchList.goodsList||[]
    },
    trademarkList(state) {
        return state.searchList.trademarkList
    },
    attrsList(state) {
        return state.searchList.attrsList
    }
}

export default {
    state,
    mutations,
    actions,
    getters
}